<template>
  <div>
    <Title2 title="设备检测"></Title2>
    <div class="right_item">
      <div class="tu">
        <img src="/src/assets/images/设备检测.png" alt="" />
      </div>
      <div class="she">
        <!-- <img src="/src/assets/images/zu.png" alt="" /> -->
        <div>
          <div>正常设备</div>
          <div>
            <el-progress
              :striped="true"
              :text-inside="true"
              :stroke-width="21"
              :percentage="70"
              :stroke-height="10"
            />
          </div>
        </div>
        <div>
          <div>异常设备</div>
          <div>
            <el-progress
              :striped="true"
              :text-inside="true"
              :stroke-width="21"
              :percentage="24"
              :stroke-height="10"
              status="exception"
            />
          </div>
        </div>
      </div>
    </div>
    <div class="right_di">
      <table>
        <thead>
          <tr>
            <td>序号</td>
            <td>设备名称</td>
            <td>设备状态</td>
          </tr>
        </thead>
        <tbody>
          <tr v-for="(item, index) in datas" :key="index">
            <td>{{ item.ettg_serial }}</td>
            <td>{{ item.ettg_type }}</td>
            <td>
              <el-switch v-model="item.ettg_status" size="small" @change="huan" />
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</template>

<script setup lang='ts'>
import Title2 from '../commont/Title2.vue'
import { onMounted, reactive, ref } from 'vue'
import { getshe } from '../../request/index'
const value1 = ref(true)
const datas = ref([])
const huan = (e) => {
  console.log(e)
}
const handleSwitchChange = (row: any) => {
  console.log('Switch changed:', row)
}

onMounted(() => {
  getshe().then((res) => {
    // console.log(res,'开启还是关闭状态')
    datas.value = res.data.data.map((item, index) => {
      if (item.ettg_status == '开启') {
        item.ettg_status = true
      } else {
        item.ettg_status = false
      }
      return item
    })
  })
})
</script>

<style scoped lang='scss'>
.right_item {
  margin-top: 10px;
  width: 100%;
  height: 150px;
  background: #0c1d5f;
  display: flex;
  align-items: center;
  justify-content: space-around;
  .tu {
    width: 40% !important;
    height: 100%;
    text-align: center;
    img {
      width: 120px;
      height: 120px;
    }
  }
  .she {
    flex: 1;
    color: #fff;
    img {
      width: 220px;
    }
  }
}
.right_di {
  height: 300px;
  margin-top: 12px;
  background: #0c1d5f;
  color: #fff;
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  table {
    border: 1px solid #eee;
    border-collapse: collapse;
  }
  td {
    width: 152px;
    height: 30px;
    text-align: center;
    border: 1px solid #ccc;
  }
}
.demo-progress .el-progress--line {
  margin-bottom: 15px;
  max-width: 600px;
}
</style>
